package com.designPatterns.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by houjinxin on 2016/11/27.
 */
public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        new BeforeAdvice().exec();
        Object returnValue = method.invoke(target, args);
        new AfterAdvice().exec();
        return returnValue;
    }
}
